package com.iams.manage.instener;

import com.iams.common.utils.spring.SpringUtils;
import com.iams.manage.domain.ArchiveDestroyApproval;
import com.iams.manage.mapper.ArchiveDestroyApprovalMapper;
import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.ExecutionListener;
import org.activiti.engine.delegate.Expression;

public class ArchiveDestroyStateListener implements ExecutionListener {

    private Expression state;
    @Override
    public void notify(DelegateExecution delegateExecution) {

        String businessKey = delegateExecution.getProcessInstanceBusinessKey();
        ArchiveDestroyApprovalMapper archiveDestroyApprovalMapper = SpringUtils.getBean(ArchiveDestroyApprovalMapper.class);
        ArchiveDestroyApproval archiveDestroyApproval = archiveDestroyApprovalMapper.selectArchiveDestroyApprovalByBusinessKey(businessKey);

        archiveDestroyApproval.setStatus(state.getValue(delegateExecution).toString());
        archiveDestroyApprovalMapper.updateArchiveDestroyApproval(archiveDestroyApproval);
    }
}
